import sys
from PyQt6.QtWidgets import QApplication
from PyQt6 import QtWidgets,QtCore,QtGui
from PyQt6.QtGui import *
from PyQt6.QtWidgets import *
import time
import PyQt6
from main_welcom import Ui_xitongwindow


class Qmywelcom(QMainWindow):
    switch_wel = QtCore.pyqtSignal()

    def __init__(self,parent=None):
        super().__init__(parent)
        self.win_wel = Ui_xitongwindow()
        self.win_wel.setupUi(self)
        self.setGeometry(700, 800, 700, 800)
        self.center()
        # self.setWindowFlag(QtCore.Qt.WindowType.FramelessWindowHint)
        # self.setAttribute(QtCore.Qt.WidgetAttribute.WA_TranslucentBackground)
        pix = QPixmap('菠萝屋.png')
        self.win_wel.label.setPixmap(pix)
        self.win_wel.label.setScaledContents(True)
        self.win_wel.pushu_welcom.clicked.connect(self.go_login_main)
        self.win_wel.pushu_welcom.setShortcut('Return')
    def go_login_main(self):
        self.switch_wel.emit()

    def center(self):
        qr = self.frameGeometry()  # 得到一个指定主窗口几何形状的矩形
        cp = self.screen().availableGeometry().center()  # 计算出显示器的分辨率，通过分辨率得出中心点
        qr.moveCenter(cp)  # 设置为屏幕的中心，矩形大小不变
        self.move(qr.topLeft())

    def paintEvent(self, event):
        painter = QPainter(self)
        pixmap = QPixmap("backgr.jpg")
        # 绘制窗口背景，平铺到整个窗口，随着窗口改变而改变
        painter.drawPixmap(self.rect(), pixmap)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('菠萝屋.jpg'))
    myWidget = Qmywelcom()
    myWidget.show()
    sys.exit(app.exec())